#include "inputelement.h"

InputElement::InputElement() {
    positionArray=0;
}

InputElement::InputElement(double* myPosition, double& myValue, const unsigned int& myDimension) {
    positionArray=new double[myDimension];
    for(unsigned int i=myDimension; i--;)
        positionArray[i]=myPosition[i];
    value=myValue;
}

InputElement::InputElement(const InputElement& ie, const unsigned int& dimension) {
    this->value=ie.value;
    this->positionArray = new double[dimension];
    double *ieArray = ie.positionArray;
    for(unsigned int i=0; i<dimension; ++i) {
        positionArray[i]=ieArray[i];
    }
}

InputElement::~InputElement() {
    if(positionArray)
        delete[] positionArray;
}

void InputElement::set(double* myPosition, double& myValue, const unsigned int& myDimension) {
    if(positionArray)
        delete[] positionArray;
    positionArray=new double[myDimension];
    for(unsigned int i=myDimension; i--;)
        positionArray[i]=myPosition[i];
    value=myValue;
}

const double& InputElement::getValue() {
    return value;
}

const double* InputElement::getPositionArray() {
    return positionArray;
}

void InputElement::set(const InputElement& ie, const unsigned int& dimension) {
    this->value=ie.value;
    this->positionArray = new double[dimension];
    double *ieArray = ie.positionArray;
    for(unsigned int i=0; i<dimension; ++i) {
        positionArray[i]=ieArray[i];
    }
}
